<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>杨澎锴的实践作业-js的练习</title>
  </head>
  <body>
    <header>
      <h2>JavaScript 变量类型练习</h2>
    </header>
    <main>
      <section>
        <ol>
          <li>number数值型</li>
          <li>对象的创建</li>
          <li>箭头函数表达式</li>
        </ol>
      </section>
    </main>
    <script>
      // 自身运算符在前面先进行自身运算，
      // 运算符在后面先进行其他的运行，在进行自身进行运算
      var a = 256;
      console.log(a.toString(2));
      // 对象的创建
      var person = {
        age: 19,
        weght: 150,
        high: 170,
        say: function (message) {
          return message;
        },
      };

      console.log(person["age"]);
      console.log(person[0]);
      person.say("hellow-world");
      console.log(person.say("hellow-world"));
      console.log(person.say);

      // 循环输出对象的属性
      for (var key in person) {
        console.log(key, person[key]);
      }
      // for (var i in person) {
      //   console.log(i);
      // }

      // 使用new运算符的方法
      var perfect = new Object();
      console.log(typeof perfect);
      perfect.wofe = "good";
      console.log(perfect.wofe);

      // 更改删除对象中的属性
      // 相当于是把变量组合，可以更改
      person.weght = 200;
      console.log(person.weght);

      // 箭头函数的使用
      () => {
        console.log("这是匿名函数当中的内容");
      };

      // 函数的参数
      function div(x, y) {
        console.log(x + y);
      }
      div(3, 5);

      // 数组练习，数组练习，数组练习
      var book = ["javaspt", "html", "css"];
      console.log(book);
      // 采用两种方式访问函数属性
      console.log(book.length, book["length"]);
      console.log(book[length]);
      // 添加数组
      book.push("java");
      // attention——从0开始
      console.log(book, book[2]);

      book2 = ["苹果", "香蕉"];
      book1 = book.concat(book2);

      console.log(book1);

      // forEach
      book1.forEach(function (item, index, array) {
        console.log(item, index, array);
      });

      // map
      book3 = book1.map(function (item) {
        // 注意输入return回到item
        return item + "flag";
      });
      console.log(book3);
      // question——使用map之后的foreach属性
      book3.forEach(function (index) {
        console.log(index);
      });

      book3.forEach((array) => {
        console.log(array);
      });

      // var numbers = [1, 4, 9];
      // var doubles = numbers.map(function (num) {
      //   return num * 2;
      // });
      // console.log(doubles);
    </script>
  </body>
</html>
